#include <vector>

using namespace std;

class Solution
{
public:
    vector<vector<int>> ans;
    vector<int> tmp;
    bool st[30];
    void dfs(int n, vector<int> &nums)
    {
        if (n == nums.size())
        {
            ans.push_back(tmp);
            return;
        }
        for (int i = 0; i < nums.size(); ++i)
        {
            if (!st[nums[i] + 10])
            {
                tmp.push_back(nums[i]);
                st[nums[i] + 10] = true;
                dfs(n + 1, nums);
                st[nums[i] + 10] = false;
                tmp.pop_back();
            }
        }
    }
    vector<vector<int>> permute(vector<int> &nums)
    {
        dfs(0, nums);
        return ans;
    }
};